home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 July: Mac OS SDK / Dev.CD Jul 97 SDK1.toast / Development Kits (Disc 1) / Interfaces&Libraries / Interfaces / PInterfaces / Translation.p < prev    next >
Encoding:
Text File  |  1995-07-06  |  11.8 KB  |  320 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        Translation.p
  3.  
  4.      Contains:    Translation Manager (Macintosh Easy Open) Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Package:    Universal Interfaces 2.1 in “MPW Latest” on ETO #18
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT Translation;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __TRANSLATION__}
  30. {$SETC __TRANSLATION__ := 1}
  31.  
  32. {$I+}
  33. {$SETC TranslationIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __TYPES__}
  38. {$I Types.p}
  39. {$ENDC}
  40. {    ConditionalMacros.p                                            }
  41.  
  42. {$IFC UNDEFINED __FILES__}
  43. {$I Files.p}
  44. {$ENDC}
  45. {    MixedMode.p                                                    }
  46. {    OSUtils.p                                                    }
  47. {        Memory.p                                                }
  48. {    Finder.p                                                    }
  49.  
  50. {$IFC UNDEFINED __COMPONENTS__}
  51. {$I Components.p}
  52. {$ENDC}
  53.  
  54. {$IFC UNDEFINED __TRANSLATIONEXTENSIONS__}
  55. {$I TranslationExtensions.p}
  56. {$ENDC}
  57. {    Quickdraw.p                                                    }
  58. {        QuickdrawText.p                                            }
  59.  
  60. {$PUSH}
  61. {$ALIGN MAC68K}
  62. {$LibExport+}
  63.     
  64. TYPE
  65.     DocOpenMethod = INTEGER;
  66.  
  67.  
  68. CONST
  69.     domCannot                    = 0;
  70.     domNative                    = 1;
  71.     domTranslateFirst            = 2;
  72.     domWildcard                    = 3;
  73.  
  74. { 0L terminated array of OSTypes, or FileTypes}
  75.     
  76. TYPE
  77.     TypesBlock = ARRAY [0..63] OF OSType;
  78.  
  79.     TypesBlockPtr = ^OSType;
  80.  
  81. { Progress dialog resource ID}
  82.  
  83. CONST
  84.     kTranslationScrapProgressDialogID = -16555;
  85.  
  86. { block of data that describes how to translate}
  87.  
  88. TYPE
  89.     FileTranslationSpec = RECORD
  90.         componentSignature:        OSType;
  91.         translationSystemInfo:    Ptr;
  92.         src:                    FileTypeSpec;
  93.         dst:                    FileTypeSpec;
  94.     END;
  95.  
  96.     FileTranslationSpecArrayPtr = ^FileTranslationSpec;
  97.  
  98. {****************************************************************************************
  99. *   GetFileTypesThatAppCanNativelyOpen
  100. *  This routine returns a list of all FileTypes that an application can open by itself
  101. *  Enter:    appVRefNumHint        volume where application resides (can be wrong, and if is, will be used as a starting point)
  102. *             appSignature        signature (creator) of application
  103. *             nativeTypes            pointer to a buffer to be filled with up to 64 FileTypes
  104. *  Exit:    nativeTypes            zero terminated array of FileTypes that can be opened by app
  105. }
  106.  
  107. FUNCTION GetFileTypesThatAppCanNativelyOpen(appVRefNumHint: INTEGER; appSignature: OSType; VAR nativeTypes: FileType): OSErr;
  108.     {$IFC NOT GENERATINGCFM}
  109.     INLINE $701C, $ABFC;
  110.     {$ENDC}
  111. {****************************************************************************************
  112. *  ExtendFileTypeList
  113. *  This routine makes a new list of file types that can be translated into a type in the given list
  114. *  Used by StandardFile
  115. *  Enter:    originalTypeList        pointer to list of file types that can be opened
  116. *             numberOriginalTypes        number of file types in orgTypeList
  117. *              extendedTypeList        pointer to a buffer to be filled with file types
  118. *             numberExtendedTypes        max number of file types that can be put in extendedTypeList
  119. *  Exit:    extendedTypeList        buffer filled in with file types that can be translated
  120. *             numberExtendedTypes        number of file types put in extendedTypeList
  121. }
  122. FUNCTION ExtendFileTypeList({CONST}VAR originalTypeList: FileType; numberOriginalTypes: INTEGER; VAR extendedTypeList: FileType; VAR numberExtendedTypes: INTEGER): OSErr;
  123.     {$IFC NOT GENERATINGCFM}
  124.     INLINE $7009, $ABFC;
  125.     {$ENDC}
  126. {****************************************************************************************
  127. *  This routine checks if a file can be opened by a particular application.
  128. *  If so, it returns if it needs to be translated first, and if so then how.
  129. *  The FileTypes that the app can open are specified by nativelyOpenableTypes,
  130. *  or if it is NULL, GetFileTypesThatAppCanNativelyOpen is called.
  131. *  Enter:    targetDocument        document to check if it can be opened
  132. *             appVRefNumHint        vRefNum of application to open doc ( can be wrong, and if is, will be used as a starting point)
  133. *             appSignature        signature (creator) of application to open doc
  134. *             nativeTypes            zero terminated list of FileTypes app can open natively, or NULL to use default list
  135. *             onlyNative            whether to consider if document can be translated before opening
  136. *             howToOpen            pointer to buffer in which to put how the document can be opened
  137. *             howToTranslate        pointer to buffer in which to put a FileTranslationSpec record
  138. *  Exit:    howToOpen            whether file needs to be translated to be read
  139. *             howToTranslate        if file can be translated, buffer filled in with how to translate
  140. *             returns                noErr, noPrefAppErr
  141. }
  142. FUNCTION CanDocBeOpened({CONST}VAR targetDocument: FSSpec; appVRefNumHint: INTEGER; appSignature: OSType; {CONST}VAR nativeTypes: FileType; onlyNative: BOOLEAN; VAR howToOpen: DocOpenMethod; VAR howToTranslate: FileTranslationSpec): OSErr;
  143.     {$IFC NOT GENERATINGCFM}
  144.     INLINE $701E, $ABFC;
  145.     {$ENDC}
  146. {****************************************************************************************
  147. *  GetFileTranslationPaths
  148. *  This routine returns a list of all ways a translation can occure to or from a FileType.
  149. *  The app is checked to exist.  The hint for each app is the VRefNum and DTRefNum
  150. *  Enter:    srcDoc            source file or NULL for all matches
  151. *             dstDoc            destination FileType or NULL for all matches
  152. *             maxResultCount
  153. *             resultBuffer
  154. *  Exit:    number of paths
  155. }
  156. FUNCTION GetFileTranslationPaths(VAR srcDocument: FSSpec; dstDocType: FileType; maxResultCount: INTEGER; resultBuffer: FileTranslationSpecArrayPtr): INTEGER;
  157.     {$IFC NOT GENERATINGCFM}
  158.     INLINE $7038, $ABFC;
  159.     {$ENDC}
  160. {****************************************************************************************
  161. *  GetPathFromTranslationDialog
  162. *  This routine, with a given document, application, and a passed typelist will display the
  163. *  Macintosh Easy Open translation dialog allowing the user to make a choice.  The choice
  164. *  made will be written as a preference (so the next call to CanDocBeOpened() will work).
  165. *  The routine returns the translation path information.
  166. *  Enter:    theDocument            FSSpec to document to open
  167. *             theApplication        FSSpec to application to open document
  168. *             typeList            Nil terminated list of FileType's (e.g. SFTypeList-like) of types
  169. *                                 you would like the documented translated to.  Order most perferred
  170. *                                 to least.
  171. *  Exit:    howToOpen            Translation method needed to open document
  172. *             howToTranslate        Translation specification
  173. *             returns                Any errors that might occur.
  174. }
  175. FUNCTION GetPathFromTranslationDialog({CONST}VAR theDocument: FSSpec; {CONST}VAR theApplication: FSSpec; typeList: TypesBlockPtr; VAR howToOpen: DocOpenMethod; VAR howToTranslate: FileTranslationSpec): OSErr;
  176.     {$IFC NOT GENERATINGCFM}
  177.     INLINE $7037, $ABFC;
  178.     {$ENDC}
  179. {****************************************************************************************
  180. *   TranslateFile
  181. *  This routine reads a file of one format and writes it to another file in another format. 
  182. *  The information on how to translated is generated by the routine CanDocBeOpened.
  183. *  TranslateFile calls through to the TranslateFile Extension's DoTranslateFile routine.  
  184. *  The destination file must not exist.  It is created by this routine.  
  185. *  Enter:    sourceDocument            input file to translate
  186. *             destinationDocument        output file of translation
  187. *             howToTranslate            pointer to info on how to translate
  188. *  Exit:    returns                    noErr, badTranslationSpecErr 
  189. }
  190. FUNCTION TranslateFile({CONST}VAR sourceDocument: FSSpec; {CONST}VAR destinationDocument: FSSpec; {CONST}VAR howToTranslate: FileTranslationSpec): OSErr;
  191.     {$IFC NOT GENERATINGCFM}
  192.     INLINE $700C, $ABFC;
  193.     {$ENDC}
  194. {****************************************************************************************
  195. *   GetDocumentKindString
  196. *  This routine returns the string the Finder should show for the "kind" of a document
  197. *  in the GetInfo window and in the kind column of a list view.  
  198. *  Enter:    docVRefNum        The volume containing the document
  199. *             docType            The catInfo.fdType of the document
  200. *             docCreator        The catInfo.fdCreator of the document
  201. *             kindString        pointer to where to return the string
  202. *  Exit:    kindString        pascal string.  Ex: "\pSurfCalc spreadsheet"
  203. *             returns            noErr, or afpItemNoFound if kind could not be determined
  204. }
  205. FUNCTION GetDocumentKindString(docVRefNum: INTEGER; docType: OSType; docCreator: OSType; VAR kindString: Str63): OSErr;
  206.     {$IFC NOT GENERATINGCFM}
  207.     INLINE $7016, $ABFC;
  208.     {$ENDC}
  209. {****************************************************************************************
  210. *  GetTranslationExtensionName
  211. *  This routine returns the translation system name from a specified TranslationSpec
  212. *  Enter:    translationMethod    The translation path to get the translation name from
  213. *  Exit:    extensionName        The name of the translation system
  214. *             returns                Any errors that might occur
  215. }
  216. FUNCTION GetTranslationExtensionName({CONST}VAR translationMethod: FileTranslationSpec; VAR extensionName: Str31): OSErr;
  217.     {$IFC NOT GENERATINGCFM}
  218.     INLINE $7036, $ABFC;
  219.     {$ENDC}
  220. {****************************************************************************************
  221. *  GetScrapDataProcPtr
  222. *  This is a prototype for the function you must supply to TranslateScrap. It is called to 
  223. *  get the data to be translated.  The first call TranslateScrap will make to this is to
  224. *  ask for the 'fmts' data.  That is a special.   You should resize and fill in the handle
  225. *  with a list all the formats that you have available to be translated, and the length of each.
  226. *  (See I.M. VI 4-23 for details of 'fmts').  It will then be called again asking for one of  
  227. *  the formats that 'fmts' list said was available.
  228. *  Enter:    requestedFormat            Format of data that TranslateScrap needs.
  229. *             dataH                    Handle in which to put the requested data
  230. *             srcDataGetterRefCon        Extra parameter for you passed to TranslateScrap
  231. *             
  232. *  Exit:    dataH                    Handle is resized and filled with data in requested format
  233. }
  234. TYPE
  235.     GetScrapDataProcPtr = ProcPtr;  { FUNCTION GetScrapData(requestedFormat: ScrapType; dataH: Handle; srcDataGetterRefCon: UNIV Ptr): OSErr; }
  236.     GetScrapDataUPP = UniversalProcPtr;
  237.  
  238. CONST
  239.     uppGetScrapDataProcInfo = $00000FE0; { FUNCTION (4 byte param, 4 byte param, 4 byte param): 2 byte result; }
  240.  
  241. FUNCTION NewGetScrapDataProc(userRoutine: GetScrapDataProcPtr): GetScrapDataUPP;
  242.     {$IFC NOT GENERATINGCFM }
  243.     INLINE $2E9F;
  244.     {$ENDC}
  245.  
  246. FUNCTION CallGetScrapDataProc(requestedFormat: ScrapType; dataH: Handle; srcDataGetterRefCon: UNIV Ptr; userRoutine: GetScrapDataUPP): OSErr;
  247.     {$IFC NOT GENERATINGCFM}
  248.     INLINE $205F, $4E90;
  249.     {$ENDC}
  250.     
  251. TYPE
  252.     GetScrapData = GetScrapDataUPP;
  253.  
  254. {****************************************************************************************
  255. *  TranslateScrap
  256. *  This routine resizes the destination handle and fills it with data of the requested format.
  257. *  The data is generated by translated one or more source formats of data supplied by
  258. *  the procedure srcDataGetter.  
  259. *  This routine is automatically called by GetScrap and ReadEdition.  You only need to call
  260. *  this if you need to translated scrap style data, but are not using the ScrapMgr or EditionMgr.
  261. *  Enter:    sourceDataGetter            Pointer to routine that can get src data
  262. *             sourceDataGetterRefCon        Extra parameter for dataGetter
  263. *             destinationFormat            Format of data desired
  264. *             destinationData                Handle in which to store translated data
  265. *             
  266. *  Exit:    dstData                        Handle is resized and filled with data in requested format
  267. }
  268.  
  269. FUNCTION TranslateScrap(sourceDataGetter: GetScrapData; sourceDataGetterRefCon: UNIV Ptr; destinationFormat: ScrapType; destinationData: Handle; progressDialogID: INTEGER): OSErr;
  270.     {$IFC NOT GENERATINGCFM}
  271.     INLINE $700E, $ABFC;
  272.     {$ENDC}
  273.  
  274. {$ALIGN RESET}
  275. {$POP}
  276.  
  277. {$SETC UsingIncludes := TranslationIncludes}
  278.  
  279. {$ENDC} {__TRANSLATION__}
  280.  
  281. {$IFC NOT UsingIncludes}
  282.  END.
  283. {$ENDC}
  284.